import Mock from "mockjs"

let originData = {
    "list|1000": [{
        title: "@ctitle(3,10)",
        "price|1-100": 1,
        num: 0,
        checked: false,
        img: "@image(100x100,@color,@city)",
        id: "@id",
        All: 0
    }]
};
let origindataold = [{
        title: "黄豆芽",
        price: "1.38",
        num: 0,
        checked: false,
        img: "@image(100x100,@color,@city)",
        id: "@id",
        All: 0
    },
    {
        title: "葫笋",
        price: "5.38",
        num: 0,
        checked: false,
        img: "@image(100x100,@color,@city)",
        id: "@id",
        All: 0
    },
    {
        title: "紫长茄",
        price: "2.58",
        num: 0,
        checked: false,
        img: "@image(100x100,@color,@city)",
        id: "@id",
        All: 0
    },
    {
        title: "紫长茄",
        price: "2.58",
        num: 0,
        checked: false,
        img: "@image(100x100,@color,@city)",
        id: "@id",
        All: 0
    }, {
        title: "紫长茄",
        price: "2.58",
        num: 0,
        checked: false,
        img: "@image(100x100,@color,@city)",
        id: "@id",
        All: 0
    }

]
console.log('origindataold', origindataold);

let data = Mock.mock(originData);
console.log('data', data);
Mock.mock("/get/list", "get", {
    code: 200,
    data: data.list
})


Mock.mock("/api/search", "post", (options) => {
    console.log('options', options);
    let {
        keyword
    } = JSON.parse(options.body);

    return {
        code: 200,
        data: data.list.filter(item => item.title.includes(keyword))
    }
})